package com.bupt.liutong.admin.shop.form;

import java.util.Date;

import org.apache.struts.upload.FormFile;

import com.bupt.liutong.admin.core.base.BaseForm;
import com.bupt.liutong.admin.core.base.Photo;
import com.bupt.liutong.admin.core.base.PhotosForm;
import com.bupt.liutong.admin.shop.dto.ProdPhoto;
import com.bupt.liutong.util.DateUtils;

public class ProdForm extends BaseForm implements PhotosForm {
	private static final long serialVersionUID = 6321011688917577706L;
	private Integer id;
	private Integer typeId;
	private Integer topTypeId;
	private String sn;
	private String name;
	private Double shopPrice;
	private String des = "";
	private String thumb = "";
	private String img = "";
	private String origImg = "";
	private Integer enabled;
	private Integer hot;
	private Date prodDate;
	private String prodDateStr;
	private Date lastUpdTime;
	
	private Integer[] attrIds = new Integer[20];
	private String[] attrVals = new String[20];
	private Integer[] attrValIds = new Integer[20];
	
	private String[] photoDeses = new String[20];
	private Integer[] photoIds = new Integer[20];
	private Integer[] photoSeqs = new Integer[20];
	
	private String[] newPhotoDeses = new String[5];
	private FormFile[] newPhotoFiles = new FormFile[5];

	public void setTypeIdStr(String typeIdStr) {
		String[] ids = typeIdStr.split(",");
		typeId = Integer.valueOf(ids[0]);
		topTypeId = Integer.valueOf(ids[1]);
	}
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getTypeId() {
		return typeId;
	}

	public void setTypeId(Integer typeId) {
		this.typeId = typeId;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Double getShopPrice() {
		return shopPrice;
	}

	public void setShopPrice(Double shopPrice) {
		this.shopPrice = shopPrice;
	}

	public String getDes() {
		return des;
	}

	public void setDes(String des) {
		this.des = des;
	}

	public String getThumb() {
		return thumb;
	}

	public void setThumb(String thumb) {
		this.thumb = thumb;
	}

	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public String getOrigImg() {
		return origImg;
	}

	public void setOrigImg(String origImg) {
		this.origImg = origImg;
	}

	public Date getLastUpdTime() {
		return lastUpdTime;
	}

	public void setLastUpdTime(Date lastUpdTime) {
		this.lastUpdTime = lastUpdTime;
	}

	public Integer[] getAttrIds() {
		return attrIds;
	}

	public void setAttrIds(Integer[] attrIds) {
		this.attrIds = attrIds;
	}

	public String[] getAttrVals() {
		return attrVals;
	}

	public void setAttrVals(String[] attrVals) {
		this.attrVals = attrVals;
	}

	public Integer getTopTypeId() {
		return topTypeId;
	}

	public void setTopTypeId(Integer topTypeId) {
		this.topTypeId = topTypeId;
	}

	public Integer getEnabled() {
		return enabled;
	}

	public void setEnabled(Integer enabled) {
		this.enabled = enabled;
	}

	public Integer getHot() {
		return hot;
	}

	public void setHot(Integer hot) {
		this.hot = hot;
	}

	public String[] getPhotoDeses() {
		return photoDeses;
	}

	public void setPhotoDeses(String[] photoDeses) {
		this.photoDeses = photoDeses;
	}

	public Integer[] getPhotoIds() {
		return photoIds;
	}

	public void setPhotoIds(Integer[] photoIds) {
		this.photoIds = photoIds;
	}

	public String[] getNewPhotoDeses() {
		return newPhotoDeses;
	}

	public void setNewPhotoDeses(String[] newPhotoDeses) {
		this.newPhotoDeses = newPhotoDeses;
	}

	public FormFile[] getNewPhotoFiles() {
		return newPhotoFiles;
	}

	public void setNewPhotoFiles(FormFile[] newPhotoFiles) {
		this.newPhotoFiles = newPhotoFiles;
	}

	public Integer[] getAttrValIds() {
		return attrValIds;
	}

	public void setAttrValIds(Integer[] attrValIds) {
		this.attrValIds = attrValIds;
	}

	
	public Photo getNewPhoto(int i) {
		ProdPhoto photo = new ProdPhoto();
		photo.setProdId(id);
		photo.setDes(this.newPhotoDeses[i]);
		photo.setFile(this.newPhotoFiles[i]);
		return photo;
	}

	
	public Photo getPhoto(int i) {
		ProdPhoto photo = new ProdPhoto();
		photo.setId(photoIds[i]);
		photo.setDes(photoDeses[i]);
		photo.setSeq(photoSeqs[i]);
		return photo;
	}

	
	public Integer[] getPhotoSeqs() {
		return photoSeqs;
	}

	
	public void setPhotoSeqs(Integer[] photoSeqs) {
		this.photoSeqs = photoSeqs;
	}

	public Date getProdDate() {
		return prodDate;
	}

	public void setProdDate(Date prodDate) {
		this.prodDate = prodDate;
		if (prodDate != null)
			prodDateStr = DateUtils.getDateStr(prodDate);
	}

	public String getProdDateStr() {
		return prodDateStr;
	}

	public void setProdDateStr(String prodDateStr) {
		this.prodDateStr = prodDateStr;
		if (prodDateStr != null)
			prodDate = DateUtils.getDate(prodDateStr);
	}
}
